home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 5106 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: news.central.ntua.gr!not-for-mail
  2. From: hnick@central.ntua.gr (Nick C. Fotis)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Disk Space Left
  5. Date: 9 Mar 1996 09:04:09 GMT
  6. Organization: National Technical University of Athens, Greece
  7. Message-ID: <4hrhi9$gba@zeus.central.ntua.gr>
  8. References: <DnL5B6.62u.0.staffin.dcs.ed.ac.uk@dcs.ed.ac.uk> <4henti$hks@btmpjg.god.bel.alcatel.be>
  9. NNTP-Posting-Host: gate2-zeus.central.ntua.gr
  10. X-Newsreader: NN version 6.5.0 #1 (NOV)
  11.  
  12. barnhoorn@nlev00 () writes:
  13.  
  14.  
  15. >In article <DnL5B6.62u.0.staffin.dcs.ed.ac.uk@dcs.ed.ac.uk>, cdc@dcs.ed.ac.uk (Christopher Carr) writes:
  16. >>    How do you correctly calculate the available disk space
  17. >>left on any single device. I am referring to the the fact that some
  18. >>small files take a minimun block size.
  19. >>
  20.  
  21. >unsigned long BP_FreeDiskMem(void)
  22. >{
  23. >        /* this function returns the number of free bytes on the current disk */
  24.  
  25. >        struct InfoData info;
  26.          ^^^^^^^^^^^^^^^^^^^^^
  27.  
  28. Will only work as long as the above struct (which will be in stack) is 
  29. quaranteed to be longword aligned.  I am not sure if thats the rule though
  30. for all the C compilers out there.
  31. (Note: If it isn't lonword alligned and it works, then dont blame me....
  32. blame the Autodocs ;-)
  33.  
  34. If you want to be Autodocs legal, you should use a pointer and try
  35. AllocMem (all OSes) or AllocVec (OS>=2.0) or you could even go for the
  36. AllocDosObject (OS>=1.3) to get space for your struct.
  37.  
  38. Hey, even malloc returns longword aligned space in all compilers AFAIK :-)
  39.  
  40. >        unsigned long size;
  41.  
  42. >        if (getdfs(0,&info)!=0)
  43. >                return 0;
  44. >        size=(info.id_NumBlocks-info.id_NumBlocksUsed)*info.id_BytesPerBlock;
  45. >        return size;
  46. >}
  47.  
  48.  
  49. >-- 
  50. >---------------------------------------------------------------------------
  51. >Jaco Barnhoorn               barnie@xs4all.nl
  52. >Software Test Engineer       barnhoorn%nlev00@btmv56.se.bel.alcatel.be
  53. >Alcatel Telecom Systems
  54. >Rijswijk, The Netherlands
  55. >---------------------------------------------------------------------------
  56. --
  57.  
  58. +----------------------------------------------------------------------------+
  59. | Alkinoos Alexandros Argiropoulos                  A1200, '030@40, 6MB Fast |
  60. | Athens, Greece                       "AAA is not a chipset...It's my name" |
  61. +----------------------------------------------------------------------------+
  62.